Quickstart: Tabular Classification with the Python API
-----------------------------------------------------------

This tutorial uses :std:ref:`RNA in quickstart` provided with NeurEco installation.

To work with the Tabular NeurEco models in Python, import **NeurEcoTabular** library:

.. code-block:: python

    from NeurEco import NeurEcoTabular as Tabular

Import numpy to handle the data sets:

.. code-block:: python

    import numpy as np 

Load the data sets (see :std:ref:`Data preparation for NeurEco Classification python API` and :std:ref:`RNA in quickstart`):

.. code-block:: python

    x_train = []
    y_train = []
    for i in range(2):
        x_name = "x_train_" + str(i) + "_.csv"
        y_name = "y_train_" + str(i) + "_.csv"
        x_part = np.genfromtxt(x_name, delimiter=";", skip_header=True)
        x_train.append(x_part)
        y_part = np.genfromtxt(y_name, delimiter=";", skip_header=True)
        y_train.append(y_part)
    x_train = np.vstack(tuple(x_train))
    y_train = np.vstack(tuple(y_train))

	x_test = np.genfromtxt("x_test.csv", delimiter=";", skip_header=True)
    y_test = np.genfromtxt("y_test.csv", delimiter=";", skip_header=True)

To initialize a NeurEco object to handle the **Classification** problem:

.. code-block:: python

    classification_model = Tabular.Classifier()

To build the model, call method **build** with the parameters set for the problem under consideration (see :std:ref:`Build NeurEco Classification model with the Python API`).

.. code-block:: python
    
    classification_model.build(input_data=x_train, output_data=y_train,
                  # the rest of these parameters are optional
                  write_model_to="./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.ednn",
                  checkpoint_address="./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.checkpoint",
                  valid_percentage=33.33)

.. note:: 
    For detailed documentation on **build**, see :std:ref:`Build NeurEco Classification model with the Python API`

To evaluate the NeurEco Model on the testing data, call **evaluate** method: 

.. code-block:: python

    neureco_test_outputs = classification_model.evaluate(x_test)

.. note::
    For detailed documentation on **evaluate**, see :std:ref:`Evaluate NeurEco Classification model with the Python API`

To export the model to the chosen format, run one of the following commands:

.. code-block:: python

    classification_model.export_c("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.h", precision="double")
    classification_model.export_onnx("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.onnx", precision="float16")
    classification_model.export_fmu("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.fmu")
    classification_model.export_vba("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.bas", precision="float")

Export to these formats requires *embed* license.

.. note::
    For detailed documentation on **export**, see :std:ref:`Export NeurEco Classification model with the Python API`

When the model is not needed any more, delete it from the memory:

.. code-block:: python

    classification_model.delete()

.. note::
    For detailed documentation on Tabular Classification with the python API, see :std:ref:`Tabular Classification with the Python API`.